package cn.zbmao.web.services.impl;


import cn.zbmao.web.bean.User;
import cn.zbmao.web.util.dao.DaoFactory;

import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: huangzheng
 * Date: 2014/11/4
 * Time: 11:29
 * To change this template use File | Settings | File Templates.
 */
public class SuccessfulServicesImpl extends abstractSuccessfulServices {

    /**
     *
     * @param userId 用户id
     * @param num 数量
     * @param orderBy 排序
     * @return
     * 获取用户关心的中标数据
     */
    @Override
    public List<Map<String, Object>> getSuccessfulForUser(int userId, int num, int orderBy) {
        return DaoFactory.getSuccessfulNewsForUserDao().getSuccessfulForUser(userId, num, orderBy);
    }

    /**
     * 获取所有付费用户，根据用户关注的信息，更新他的中标数据
     */
    @Override
    public void putSuccessfulForUser() {
        List<User> users =  DaoFactory.getUserDao().getPayUsers();
        for (User user : users){
            initNews(user.getInt("id"));
        }
    }
}
